var app = new Vue({
    el: '#turn-app',
    data: {
        title: '',
        money: '',
        popupVisible: false, //遮盖层
        msg: '', //操作密码
        showplaceholder: true // 是否显示placeholder
    },
    computed: {
        chineseTitle() {
            switch (this.title) {
                case 'zhuanru':
                    return '转入';
                case 'zhuanchu':
                    return '转出';
                default:
                    return '';
            }
        },
        btnDisabled() {
            if(this.money) return false;
            return true;
        },
        confirmDisabled() {
            if(this.msg.length === 6) return false;
            return true;
        }
    },
    created() {
        this.title = utils.getSearchParam();
        document.title = `资金${this.chineseTitle}`;
    },
    methods: {
        btnClick() {
            if(this.btnDisabled) return;

            const moneyReg = new RegExp(regExpConfig.money);
            if(!moneyReg.test(this.money) || this.money <= 0) {
                this.$toast('请输入正确的金额');
                return;
            }
            this.popupVisible = true;
        },
        modalBtnClick(param) {
            if(param === 1 && this.confirmDisabled) {
                return;
            }
            this.popupVisible = false;
            this.msg = "";
        },
        focus() {
            this.$refs.pwd.focus();
        },
        togglePlaceholder() {
            this.showplaceholder = !this.showplaceholder;
        }
    }
});